﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="top.ascx.cs" Inherits="HFWebApp.Control.top" %>
<script type="text/javascript">
    $(function () {
        checkLogin();
        //alert('test');
    });
    //绑定分数
    function bindOption(obj ,pp) {
        var points = $("#" + obj);
        //alert(pp)
        var j = pp;
        var html = '<option value="$i$">$i$</option>';
        var outHtml = '';
        
        for (var i = 1; i < j+1; i++) {
            if (outHtml == '') {
                outHtml = '<option value="' + i.toString() + '">' + i.toString() + '</option>';
            } else {
                outHtml += '<option value="' + i.toString() + '">' + i.toString() + '</option>';
            }
        }
        points.empty();
        points.append(outHtml);
        points.prepend("<option value='0'>0</option>"); //在前面插入一项option
    }

    function checkLogin() {
        var url = "/AjaxSource/CheckUserRemember.ashx";
        $.getJSON(
            url,
            { TypeID: "1", rand: Math.floor(Math.random() * 10000).toString() },
            function (jsonData) {
                if (jsonData.isTrue) {
                    $("#loginPlan").hide();
                    $("#infoPlan").show();
                    $("#UserNameSpan").html(jsonData.Message.split("|")[0]);
                    try {
                        //alert(jsonData.Message.split("|")[1]);
                        bindOption("ask_points", parseInt(jsonData.Message.split("|")[1]));
                        $("#nowPoint").html(jsonData.Message.split("|")[1]);
                    } catch (e) { alert(e.toString()); }

                } else {
                    //alert(jsonData.isTrue);
                    try {
                        $("#nowPoint").html(jsonData.Message.split("|")[0]);
                    } catch (e) { }
                    checkRemeber();
                }
            }
        );
    }

    function checkRemeber() {
        var url = "/AjaxSource/CheckUserRemember.ashx";
        $.getJSON(
            url,
            { TypeID: "0", rand: Math.floor(Math.random() * 10000).toString() },
            function (jsonData) {
                if (jsonData.isTrue) {
                    var Message = jsonData.Message.split(",");
                    $("#login_uid").val(Message[0]);
                    $("#login_pwd").val(Message[1]);
                    $("#login_isRem").attr("checked", true);
                } else {
                    $("#login_uid").val("");
                    $("#login_pwd").val("");
                    $("#login_isRem").attr("checked", false);
                }
            }
        );
    }

    function userLogin() {
        var url = "/AjaxSource/UserLogin.ashx";
        var uid = $("#login_uid").val();
        var pwd = $("#login_pwd").val();
        var isMem = "0";
        if ($("#login_isRem").attr("checked")) {
            isMem = "1";
        }
        $.getJSON(
            url,
            { login_uid: uid, login_pwd: pwd, login_isRem: isMem, rand: Math.floor(Math.random() * 10000).toString() },
            function (jsonData) {
                if (jsonData.isTrue) {
                    $("#loginPlan").hide();
                    $("#infoPlan").show();
                    $("#UserNameSpan").html(jsonData.Message.split("|")[0]);
                    try {
                        $("#message_Span").hide();
                        $("#btn_Span").show();
                        bindOption("ask_points", jsonData.Message.split("|")[1]);
                        $("#nowPoint").html(jsonData.Message.split("|")[1]);
                    } catch (e) { alert(e.toString()); }
                    //刷新本页
                    window.location.reload();
                } else {
                    try {
                        $("#btn_Span").hide();
                        $("#message_Span").show();
                        $("#nowPoint").html("0");
                    } catch (e) { }
                    alert(jsonData.Message);
                }
            }
        );
        return false;
     }
</script>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
<form id="loginForm" onsubmit="return userLogin();">
  <tr id="loginPlan">
    <td width="59" height="33" align="right">用户名：</td>
    <td width="104"><input name="login_uid" type="text" id="login_uid" size="14" /></td>
    <td width="46" align="right">密码：</td>
    <td width="110"><input name="login_pwd" type="password" id="login_pwd" size="14" /></td>
    <td width="45" align="right">记住我</td>
    <td width="24" align="right"><input type="checkbox" name="login_isRem" id="login_isRem" /></td>
    <td width="60" align="center"><input  id="Button1" type="image" src="<%=bg.getDemain %>/images/an_dl.jpg" /></td>
    <td width="150" class="h_12">[<a href="<%=bg.getDemain %>/registerindex.aspx" class="linkcolor4">免费注册</a>] [<a href="<%=bg.getDemain %>/Find.aspx" class="linkcolor4">忘记密码</a>]</td>
    <td align="right" class="link_txt"><a href="javascript:SetHome(this,window.location);">设为首页</a> | <a href="javascript:AddFavorite(window.location,document.title);">加入收藏</a> | <a href="<%=bg.getDemain %>/line.aspx">在线律师</a></td>
  </tr>
  </form>
  <tr id="infoPlan" style=" display:none; ">
    <td width="499" height="33" align="left">&nbsp;&nbsp;欢迎您：<span id="UserNameSpan"></span>&nbsp;&nbsp;&nbsp;&nbsp; <a href="/goUserCenter.aspx">用户中心</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a href="<%=bg.getDemain %>/logout.aspx">注销</a></td>
    <td align="right" class="link_txt"><a href="javascript:SetHome(this,window.location);">设为首页</a> | <a href="javascript:AddFavorite(window.location,document.title);">加入收藏</a> | <a href="<%=bg.getDemain %>/line.aspx">在线律师</a></td>
  </tr>
</table>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0" class="top_bj">
  <tr>
    <td width="250" height="96" style="padding-left:10px"><img src="<%=bg.getDemain %>/images/logo.jpg" width="219" height="54" /></td>
    <td align="left">
        <span class="class_fenzhan_title"><%=NowCity%></span><br />
        <a href="javascript:;" class="message">[切换城市]</a>
    </td>
    <td align="right"><table width="440" border="0" cellspacing="0" cellpadding="0" style="margin-right:10px">
      <tr>
        <td height="30" align="right"><table border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="70" align="left"><strong>热门搜索：</strong></td>
            <td align="left">咨询　律师　法规　合同　案例</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td height="42" align="right"><table width="432" border="0" cellspacing="0" cellpadding="0">
          <form id="searchForm" action="/search.aspx" method="post">
          <tr>
            <td width="77" height="42" align="center" background="<%=bg.getDemain %>/images/ss_bj.jpg"><span class="bj_ss">
              <select name="typeid" id="typeid" style="background-color: transparent;border-style: solid; border:0px solid #fffaf6;" >
                <option value="1">咨询</option>
                <option value="2">律师</option>
                <option value="3">法规</option>
                <option value="4">合同</option>
                <option value="5">案例</option>
              </select>
            </span></td>
            <td width="281" align="left" background="<%=bg.getDemain %>/images/ss_bj_1.jpg"><span class="bj_ss1" style="padding-left:6px">
              <input style="background-color: transparent;border-style: solid; border:0px solid #FFFFFF;" value="" id="wordkey" name="wordkey" size="38" />
            </span></td>
            <td><input id="Button2"  type="image" src="<%=bg.getDemain %>/images/ss_an.jpg" /></td>
          </tr>
          </form>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
<div style=" width:100%; overflow:hidden; height:43px; background:url(<%=bg.getDemain %>/images/dh_bj.jpg)">
    <div id="main_nav">
          <ul>
            <li><a href="<%=bg.getDemain %>/Default.aspx" class="<%=focusLink1 %>">网站首页</a></li>
            <li><img alt="" src="<%=bg.getDemain %>/images/ee.jpg" width="2" height="43" /></li>
            <li><a href="<%=bg.getDemain %>/flzx.aspx" class="<%=focusLink2 %>">法律咨询</a></li>
            <li><img alt="" src="<%=bg.getDemain %>/images/ee.jpg" width="2" height="43" /></li>
            <li><a href="<%=bg.getDemain %>/zhao.aspx" class="<%=focusLink3 %>">找律师</a></li>
            <li><img alt="" src="<%=bg.getDemain %>/images/ee.jpg" width="2" height="43" /></li>
            <li><a href="<%=bg.getDemain %>/line.aspx" class="<%=focusLink4 %>">律师在线</a></li>
            <li><img alt="" src="<%=bg.getDemain %>/images/ee.jpg" width="2" height="43" /></li>
            <li><a href="<%=bg.getDemain %>/zixun.aspx" class="<%=focusLink5 %>">法治资讯</a></li>
            <li><img alt="" src="<%=bg.getDemain %>/images/ee.jpg" width="2" height="43" /></li>
            <li><a href="<%=bg.getDemain %>/fagui.aspx" class="<%=focusLink6 %>">法律法规</a></li>
            <li><img alt="" src="<%=bg.getDemain %>/images/ee.jpg" width="2" height="43" /></li>
            <li><a href="<%=bg.getDemain %>/ziliao.aspx" class="<%=focusLink7 %>">法律资料</a></li>
            <li><img alt="" src="<%=bg.getDemain %>/images/ee.jpg" width="2" height="43" /></li>
            <li><a href="<%=bg.getDemain %>/wenshu.aspx" class="<%=focusLink8 %>">法律文书</a></li>
          </ul>
        </div>
</div>
<table border="0" cellspacing="0" cellpadding="0" style="margin-bottom:9px; margin-left:auto; margin-right:auto; width:100%;">
  <tr>
    <td height="31" align="left" style=" background:url(<%=bg.getDemain %>/images/dh_bj_x.jpg);">
    <div style=" width:950px; height:31px; line-height:31px; margin-left:auto; margin-right:auto">
        <%foreach (HFModel.VO.MenuData d in list) { 
          %>
          ◎ <a href="<%=d.Link %>"><%=d.Title %></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <%
          } %>
    </div></td>
  </tr>
</table>
